package com.xf.day04

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}
/**
 * 具体的 spark UI 的地址:
 *    http://127.0.0.1:8080/
 */
object WordCount {
  def main(args: Array[String]): Unit = {
    sparkTest()
  }

  private def sparkTest(): Unit = {
    val conf = new SparkConf()
      .setAppName("WordCount")
      .setMaster("local[*]")
      .set("spark.ui.port", "8080")
      .set("spark.driver.host", "127.0.0.1")

    val sc = new SparkContext(conf)

    val words: Array[String] = Array("Spark", "is", "cool")

    val rdd: RDD[String] = sc.parallelize(words)

    rdd.foreach(x => println(x))

    // 暂停 10 秒，方便查看 UI
    Thread.sleep(10000000)
  }
}
